package com.itboy.mall.pms.product.controller;

import com.itboy.common.core.controller.BaseController;
import com.itboy.common.core.domain.AjaxResult;
import com.itboy.mall.pms.product.domain.SpuSaveInfo;
import com.itboy.mall.pms.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品Controller
 *
 * @author itboy
 * @date 2021-08-07
 */
@Validated
@Api(value = "商品控制器", tags = {"商品管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/mall/product")
public class ProductController extends BaseController {


	private final ProductService productService;

	@ApiOperation("添加商品")
	@PostMapping("/saveProduct")
	public AjaxResult<Void> add(@Validated @RequestBody SpuSaveInfo spuSaveInfo) {
		return toAjax(productService.save(spuSaveInfo) ? 1 : 0);
	}

}
